# Rating

The `<Rating>` component displays a set of selectable (or static) rating stars.

## Import

```jsx
import { Rating } from 'bumbag';
```

## Usage

```function-live
function Example() {
  const [value, setValue] = React.useState(3);
  return (
    <Rating
      onChange={value => setValue(value)}
      value={value}
    />
  );
}
```

### Static

Render a set of static unselectable stars with the `isStatic` prop.

```function-live
function Example() {
  const [value, setValue] = React.useState(3);
  return (
    <Rating
      isStatic
      onChange={value => setValue(value)}
      value={value}
    />
  );
}
```

### Disabled

Disable the selectable stars with a `disabled` prop.

```function-live
function Example() {
  const [value, setValue] = React.useState(3);
  return (
    <Rating
      disabled
      onChange={value => setValue(value)}
      value={value}
    />
  );
}
```

### Sizes

```function-live
function Example() {
  const [value, setValue] = React.useState(3);
  return (
    <Stack spacing="major-2">
      <Rating
        size="small"
        onChange={value => setValue(value)}
        value={value}
      />
      <Rating
        onChange={value => setValue(value)}
        value={value}
      />
      <Rating
        size="medium"
        onChange={value => setValue(value)}
        value={value}
      />
      <Rating
        size="large"
        onChange={value => setValue(value)}
        value={value}
      />
    </Stack>
  );
}
```

### Max rating

```function-live
function Example() {
  const [value, setValue] = React.useState(3);
  return (
    <Rating
      maxValue={10}
      onChange={value => setValue(value)}
      value={value}
    />
  );
}
```

### Custom items

```function-live
function Example() {
  const [value, setValue] = React.useState(3);
  return (
    <Rating
      item={<Icon icon="solid-igloo" />}
      onChange={value => setValue(value)}
      value={value}
    />
  );
}
```

```function-live
function Example() {
  const [value, setValue] = React.useState();
  return (
    <Rating
      isSingular
      color="primary"
      items={[
        <Icon icon="solid-frown" />,
        <Icon icon="solid-meh" />,
        <Icon icon="solid-smile" />
      ]}
      size="large"
      onChange={value => setValue(value)}
      value={value}
    />
  );
}
```

## Accessibility

#### Patterns

- `Rating` extends the accessibility features of the [RadioGroup component](/form/radio-group).
- The `aria-checked` attribute is set to `true` on the item which is currently selected.
- The `aria-posinset` attribute is set to the position of the rating item.
- The `aria-setsize` attribute is set to the max value of the rating set.
- The `Rating.Item` has a role of `radio`.

## Props

### Rating Props

<!-- Automatically generated -->

**<Code fontSize="150" marginRight="major-1">color</Code>** <Code fontSize="100" palette="primary">string</Code> 

Sets the color of the rating items.

<Divider marginTop="major-2" marginBottom="major-2" />

**<Code fontSize="150" marginRight="major-1">disabled</Code>** <Code fontSize="100" palette="primary">boolean</Code> 

Indicates if the rating is disabled.

<Divider marginTop="major-2" marginBottom="major-2" />

**<Code fontSize="150" marginRight="major-1">item</Code>**  

<Code isBlock palette="primary" fontSize="150" padding="minor-1" marginBottom="major-2">
{`ReactElement<any, string
  | ((props: any) => ReactElement<any, string
  | ...
  | (new (props: any) => Component<any, any, any>)>)
  | (new (props: any) => Component<any, any, any>)>`}
</Code>

Sets the custom item component.

<Divider marginTop="major-2" marginBottom="major-2" />

**<Code fontSize="150" marginRight="major-1">items</Code>**  

<Code isBlock palette="primary" fontSize="150" padding="minor-1" marginBottom="major-2">
{`ReactElement<any, string
  | ((props: any) => ReactElement<any, string
  | ...
  | (new (props: any) => Component<any, any, any>)>)
  | (new (props: any) => Component<any, any, any>)>[]`}
</Code>

Sets the items of the rating.

<Divider marginTop="major-2" marginBottom="major-2" />

**<Code fontSize="150" marginRight="major-1">isSingular</Code>** <Code fontSize="100" palette="primary">boolean</Code> 

Indicates if the rating is radio.

<Divider marginTop="major-2" marginBottom="major-2" />

**<Code fontSize="150" marginRight="major-1">isStatic</Code>** <Code fontSize="100" palette="primary">boolean</Code> 

Indicates the rating is static.

<Divider marginTop="major-2" marginBottom="major-2" />

**<Code fontSize="150" marginRight="major-1">maxValue</Code>** <Code fontSize="100" palette="primary">number</Code> 

Sets the max value.

<Divider marginTop="major-2" marginBottom="major-2" />

**<Code fontSize="150" marginRight="major-1">onChange</Code>** <Code fontSize="100" palette="primary">(index: number) =&#62; void</Code> <Text marginLeft="major-1" fontSize="150" textTransform="uppercase" color="gray">Required</Text>

Function to invoke when the rating has changed.

<Divider marginTop="major-2" marginBottom="major-2" />

**<Code fontSize="150" marginRight="major-1">size</Code>**  

<Code isBlock palette="primary" fontSize="150" padding="minor-1" marginBottom="major-2">
{`"default"
  | (string & {})
  | "small"
  | "medium"
  | "large"`}
</Code>

Sets the size of the rating items.

<Divider marginTop="major-2" marginBottom="major-2" />

**<Code fontSize="150" marginRight="major-1">value</Code>** <Code fontSize="100" palette="primary">number | void</Code> <Text marginLeft="major-1" fontSize="150" textTransform="uppercase" color="gray">Required</Text>

Sets the value of the rating.

<Divider marginTop="major-2" marginBottom="major-2" />

**<Code fontSize="150" marginRight="major-1">roverProps</Code>** <Code fontSize="100" palette="primary">{ baseId?: string; stopId?: string; }</Code> 

<Divider marginTop="major-2" marginBottom="major-2" />

<details><Box use="summary" marginBottom="major-2">Inherits <strong><code>Flex</code></strong> props</Box>

</details>
            

<details><Box use="summary" marginBottom="major-2">Inherits <strong><code>Box</code></strong> props</Box>

**<Code fontSize="150" marginRight="major-1">use</Code>**  

<Code isBlock palette="primary" fontSize="150" padding="minor-1" marginBottom="major-2">
{`string
  | (ComponentClass<any, any> & { useProps: any; })
  | (FunctionComponent<any> & { useProps: any; })`}
</Code>

<Divider marginTop="major-2" marginBottom="major-2" />

**<Code fontSize="150" marginRight="major-1">className</Code>** <Code fontSize="100" palette="primary">string</Code> 

<Divider marginTop="major-2" marginBottom="major-2" />

**<Code fontSize="150" marginRight="major-1">children</Code>**  

<Code isBlock palette="primary" fontSize="150" padding="minor-1" marginBottom="major-2">
{`string
  | number
  | boolean
  | {}
  | ReactElement<any, string
  | ((props: any) => ReactElement<any, string
  | ...
  | (new (props: any) => Component<any, any, any>)>)
  | (new (props: any) => Component<...>)>
  | ReactNodeArray
  | ReactPortal
  | ((props: BoxProps) => ReactNode)`}
</Code>

<Divider marginTop="major-2" marginBottom="major-2" />

**<Code fontSize="150" marginRight="major-1">alignX</Code>** <Code fontSize="100" palette="primary">&#34;right&#34; | &#34;left&#34; | &#34;center&#34;</Code> 

<Divider marginTop="major-2" marginBottom="major-2" />

**<Code fontSize="150" marginRight="major-1">alignY</Code>** <Code fontSize="100" palette="primary">&#34;top&#34; | &#34;bottom&#34; | &#34;center&#34;</Code> 

<Divider marginTop="major-2" marginBottom="major-2" />

**<Code fontSize="150" marginRight="major-1">variant</Code>** <Code fontSize="100" palette="primary">string</Code> 

<Divider marginTop="major-2" marginBottom="major-2" />

**<Code fontSize="150" marginRight="major-1">colorMode</Code>** <Code fontSize="100" palette="primary">string</Code> 

<Divider marginTop="major-2" marginBottom="major-2" />

**<Code fontSize="150" marginRight="major-1">overrides</Code>**  

<Code isBlock palette="primary" fontSize="150" padding="minor-1" marginBottom="major-2">
{`{
  useCSSVariables?: boolean;
  altitudes?: AltitudesThemeConfig;
  borders?: BordersThemeConfig;
  borderRadii?: BorderRadiiThemeConfig;
  ... 96 more ...;
  Template?: TemplateThemeConfig;
}`}
</Code>

<Divider marginTop="major-2" marginBottom="major-2" />

**<Code fontSize="150" marginRight="major-1">elementRef</Code>** <Code fontSize="100" palette="primary">((instance: any) =&#62; void) | RefObject&#60;any&#62;</Code> 

<Divider marginTop="major-2" marginBottom="major-2" />

**<Code fontSize="150" marginRight="major-1">themeKey</Code>** <Code fontSize="100" palette="primary">string</Code> 

<Divider marginTop="major-2" marginBottom="major-2" />

</details>
            

### Theming

<Theme component={'Rating'} onChange={() => {}} value={3} overrides={['Rating.styles.base', 'Rating.Item.styles.base']} />
